#ifndef DW_SYSTEM_WINDOW_H
#   define DW_SYSTEM_WINDOW_H

namespace dw {
    namespace system {

class Window
{
public : //! @name Constants
	//! @{
	static const uint NAME_MAX_LENGTH = 32;
	static const uint TITLE_MAX_LENGTH = 32;
	//! @}

public : //! @name Types definitions
	//! @{
	struct Setup
	{
		Setup();
		Setup(int32 pLeft, int32 pTop, uint32 pWidth, uint32 pHeight, uint32 pBitDepth = 32, bool pFullScreen = false);

		int32 left;
		int32 top;
		uint32 width;
		uint32 height;
		uint32 bitDepth;
		bool fullScreen;
	};

	class EventArg;
	class PaintEventArg;
	class MoveEventArg;
	class SizeEventArg;
	class MouseEventArg;
	class KeyEventArg;

	class EventListener;
	//! @}

public : //! @name Construction & destruction
	//! @{
	Window(char* name, const Setup& setup);
	Window(char* name, uint32 width, uint32 height, uint32 bitDepth = 32, bool fullScreen = false);
	~Window();
	//! @}

public : //! @name EventListeners Commands
	//! @{
	void registerListener(EventListener* listener);
	void unregisterListener(EventListener* listener);
	//! @}

public : //! @name Commands
	//! @{
	void show();
	void hide();
	//! @}

public : //! @name Setup
	//! @{
	void setTitle(const char* title);
	//! @}

public : //! @name State
	//! @{
	const char* getName() const ;
	uint32 getWidth() const ;
	uint32 getHeight() const ;
	uint32 getBitDepth() const ;
	bool isActive() const ;
	HWND getHandle() const ;
	HDC getDeviceContext() const ;
	//! @}

public : //! @name Callbacks
	//! @{
	void onPaint();
	void onActivate();
	void onDeactivate();
	void onMove(int32 left, int32 top);
	void onSize(uint32 width, uint32 height);
	void onKeyDown(int32 key);
	void onKeyUp(int32 key);
	void onClose();
	//! @}

private : //! @name Constants
	//! @{
	static const uint CLASS_NAME_SUFFIX_LENGTH = 8;
	static const uint CLASS_NAME_MAX_LENGTH = NAME_MAX_LENGTH + CLASS_NAME_SUFFIX_LENGTH;
	static const char CLASS_NAME_SUFFIX[CLASS_NAME_SUFFIX_LENGTH];
	//! @}

private : //! @name Types definitions
	//! @{
	typedef std::vector< EventListener* > ListenersCollection;
	//! @}

private : //! @name Helpers
	//! @{
	void create();
	void destroy();
	//! @}

private : //! @name Data
	//! @{
	char _name[NAME_MAX_LENGTH];
	char _className[CLASS_NAME_MAX_LENGTH];

	char _title[TITLE_MAX_LENGTH];

	HINSTANCE _hInstance;
	HWND _hWnd;

	Setup _setup;

	bool _isActive;

	ListenersCollection _listeners;
	//! @}
};

	} // namespace system
} // namespace dw

#endif // !DW_SYSTEM_WINDOW_H
